<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head th:replace="public::head('投票表决')">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta charset="UTF-8"></meta>

</head>
<body style="padding-top:50px;">
<input type="hidden" th:value="${session.Id}" id="id"/>
<input type="hidden" th:value="${session.Type}" id="Type"/>

<div th:replace="public/top_vote::top"></div>

<div id="Votelist">
    <div th:replace="vote/edit_shiyongyuanze::editShiyongyuanze"></div>
    <div class="primary-title">
        <div style="margin-top:15px;text-align: center;font-size:24px">
            <label  style="margin-left: 20px; ">{{xiangmu.xiangmuname}}</label>
        </div>
        <div style="text-align: center;font-size:18px;">
            <label  style="margin-left: 20px; ">总数： {{total}} 同意： <font color="green">{{tongyishu}}</font> 不同意： <font color="red">{{butongyishu}}</font></label>
            <input v-if="!issubmited" type="button" class="btn btn-sm btn-primary" style="width: 60px" value="提交" @click="tosubmit()">
            <input v-if="issubmited" type="button" class="btn btn-sm btn-success" disabled style="width: 60px" value="已提交" >
        </div>
        <div>
            <input v-if="!issubmited" type="button" class="btn btn-sm btn-danger" style="width:80px;margin-right: 10px;float: right" value="一键不同意" @click="toVoteAll(0)">
            <input v-if="!issubmited" type="button" class="btn btn-sm btn-success" style="width:80px;margin-right: 10px;float: right" value="一键同意" @click="toVoteAll(1)">
        </div>
    </div>


    <div class="primary-content">
        <div class='table-head'>
            <table class="table table-hover table-striped" style="overflow:hidden; margin-bottom:10px;table-layout:fixed;height:60px;">
                <thead>
                <tr style="font-weight: bold;">
                <td style="text-align:center;vertical-align:middle;width:60px;">序号</td>
                <td style="text-align:center;vertical-align:middle;width:160px;">科室名称</td>
                <td style="text-align:center;vertical-align:middle;width:160px;">设备名称</td>
                <td style="text-align:center;vertical-align:middle;width:160px;">通用名称</td>
                <td style="text-align:center;vertical-align:middle;width:80px;">预算单价（万元）</td>
                <td style="text-align:center;vertical-align:middle;width:60px;">数量</td>
                <td style="text-align:center;vertical-align:middle;width:80px;">预算金额（万元）</td>
                <td style="text-align:center;vertical-align:middle;width:80px;">更新/新增</td>
                <td style="text-align:center;vertical-align:middle;width:160px;">配置理由</td>
                <td style="text-align:center;vertical-align:middle;width:100px;">备注</td>
                <td style="text-align:center;vertical-align:middle;width:80px;">选择理由</td>
                <td style="text-align:center;vertical-align:middle;width:160px;">表决建议</td>
                </tr>
                </thead>
            </table>
        </div>
        <div class='table-body'>
            <table style="table-layout: fixed;">
                <tbody>
            <tr v-for="(voteitem,index) in votelist" v-if="show" >
                <td style="text-align:center;vertical-align:middle;width:60px;" v-text="index+1"></td>
                <td style="text-align:center;vertical-align:middle;width:160px;" v-text="voteitem.shiyongkeshi"></td>
                <td style="text-align:center;vertical-align:middle;width:160px;" v-text="voteitem.shebeimingcheng"></td>
                <td style="text-align:center;vertical-align:middle;width:160px;" v-text="voteitem.tongyongmingcheng"></td>
                <td style="text-align:center;vertical-align:middle;width:80px;" v-text="voteitem.danjia"></td>
                <td style="text-align:center;vertical-align:middle;width:60px;" v-text="voteitem.shuliang"></td>
                <td style="text-align:center;vertical-align:middle;width:80px;" v-text="voteitem.yusuanjine"></td>
                <td style="text-align:center;vertical-align:middle;width:80px;" v-text="voteitem.shebeileixing"></td>
                <td style="text-align:center;vertical-align:middle;width:160px;overflow: hidden;text-overflow: ellipsis;white-space:nowrap;" >
                 <!--   <a style='text-align:center;vertical-align:middle;white-space:nowrap;text-overflow: ellipsis; overflow: hidden;display: -webkit-box;'
                       :title="voteitem.beizhu">{{voteitem.beizhu}}</a>-->
                    <a :title="voteitem.beizhu1">{{voteitem.beizhu1}}</a>
                </td>
                <td style="text-align:center;vertical-align:middle;width:100px;overflow: hidden;text-overflow: ellipsis;white-space:nowrap;" >
                    <!--   <a style='text-align:center;vertical-align:middle;white-space:nowrap;text-overflow: ellipsis; overflow: hidden;display: -webkit-box;'
                          :title="voteitem.beizhu">{{voteitem.beizhu}}</a>-->
                    <a :title="voteitem.beizhu">{{voteitem.beizhu}}</a>
                </td>
               <!-- <td style="text-align:center;vertical-align:middle;width:100px;" >
                <div style="text-align:center;">
                    <input type="button" class="btn btn-sm btn-info" value="查看" @click="toshowDetail(voteitem.beizhu)">
                </div>
                </td>-->
                <td style="text-align:center;vertical-align:middle;width:80px;">
                    <div style="text-align: center" :id="'yuanze_'+voteitem.id">
                        <span v-if="voteitem.shiyongyuanzeid!=null" >{{voteitem.shiyongyuanzeid}}</span>
                    </div>
                    <div style="text-align:center;">
                        <input v-if="!issubmited" type="button" class="btn btn-sm btn-primary" style="width:60px;margin-left: 10px;float: left" value="选择" @click="toModify(voteitem.id,voteitem.ordernumber)">
                    </div>
                </td>
                <td style="text-align:center;vertical-align:middle;width:160px;" >
                    <div style="text-align: center" :id="'jieguo'+voteitem.id">
                        <span v-if="voteitem.result==null" style="color:blue">未表决</span>
                        <span v-if="voteitem.result==0" style="color:red">不同意</span>
                        <span v-if="voteitem.result==1" style="color:green">同意</span>
                    </div>
                    <div style="text-align:center;">
                        <input v-if="!issubmited" type="button" class="btn btn-sm btn-success" style="width:60px;margin-left: 10px;float: left" value="同意" @click="toVote(voteitem.id,1)">
                        <input v-if="!issubmited" type="button" class="btn btn-sm btn-danger" style="width:60px;margin-left: 10px;float: left" value="不同意" @click="toVote(voteitem.id,0)">
                    </div>
                </td>
            </tr>
            </tbody>
            </table>
        </div>
        <div v-if="!show" style="text-align:center;width:100%;">暂无数据</div>


    </div>



</div>

</body>
<style>
    .hong{
        background-color: red;
    }
    table{
        border:1px solid #e6e6e6;
        /*line-height: 5vh;*/
        color:#666666;
        font-size: 16px;
    }
    table {
        border-collapse: collapse;
        width: 100%;
    }
    td {
        padding:5px;
        border:1px solid #e6e6e6;
        font-size: 14px;
    }
    .table-head{padding-right:20px;background-color: #CDCDCD;color:#000;margin-top:80px;height:60px;}
    .table-body{width:100%; height:500px;overflow-y:scroll;}
    .table-head table,.table-body table{width:100%;}
    /*.table-body table tr:nth-child(2n+1){background-color: #CDCDCD;}*/

    .table-body table tr:hover {
        background-color:#dff0d8;
        transition: .2s;
    }
    .table-body table tr:hover td{background-color:rgb(240, 249, 228);}
</style>
<script th:src="@{/js/vote/list_yinjin_vote.js}"></script>

<script type="text/javascript">
    var ID = $("#id").val();
    var ID = $("#id").val();

    var dragModal={
        mouseStartPoint:{"left":0,"top":  0},
        mouseEndPoint : {"left":0,"top":  0},
        mouseDragDown : false,
        basePoint : {"left":0,"top":  0},
        moveTarget:null,
        topleng:0
    }
    $(document).on("mousedown",".modal-header",function(e){
        //webkit内核和火狐禁止文字被选中
        $('body').addClass('select')
        //ie浏览器禁止文字选中
        document.body.onselectstart=document.body.ondrag=function(){
            return false;
        }
        if($(e.target).hasClass("close"))//点关闭按钮不能移动对话框
            return;
        dragModal.mouseDragDown = true;
        dragModal.moveTarget = $(this).parent().parent();
        dragModal.mouseStartPoint = {"left":e.clientX,"top":  e.pageY};
        dragModal.basePoint = dragModal.moveTarget.offset();
        dragModal.topLeng=e.pageY-e.clientY;
    });
    $(document).on("mouseup",function(e){
        dragModal.mouseDragDown = false;
        dragModal.moveTarget = undefined;
        dragModal.mouseStartPoint = {"left":0,"top":  0};
        dragModal.basePoint = {"left":0,"top":  0};
    });
    $(document).on("mousemove",function(e){
        if(!dragModal.mouseDragDown || dragModal.moveTarget == undefined)return;
        var mousX = e.clientX;
        var mousY = e.pageY;
        if(mousX < 0)mousX = 0;
        if(mousY < 0)mousY = 25;
        dragModal.mouseEndPoint = {"left":mousX,"top": mousY};
        var width = dragModal.moveTarget.width();
        var height = dragModal.moveTarget.height();
        var clientWidth=document.body.clientWidth
        var clientHeight=document.body.clientHeight;
        if(dragModal.mouseEndPoint.left<dragModal.mouseStartPoint.left - dragModal.basePoint.left){
            dragModal.mouseEndPoint.left=0;
        }
        else if(dragModal.mouseEndPoint.left>=clientWidth-width+dragModal.mouseStartPoint.left - dragModal.basePoint.left){
            dragModal.mouseEndPoint.left=clientWidth-width-38;
        }else{
            dragModal.mouseEndPoint.left =dragModal.mouseEndPoint.left-(dragModal.mouseStartPoint.left - dragModal.basePoint.left);//移动修正，更平滑

        }
        if(dragModal.mouseEndPoint.top-(dragModal.mouseStartPoint.top - dragModal.basePoint.top)<dragModal.topLeng){
            dragModal.mouseEndPoint.top=dragModal.topLeng;
        }else if(dragModal.mouseEndPoint.top-dragModal.topLeng>clientHeight-height+dragModal.mouseStartPoint.top - dragModal.basePoint.top){
            dragModal.mouseEndPoint.top=clientHeight-height-38+dragModal.topLeng;
        }
        else{
            dragModal.mouseEndPoint.top = dragModal.mouseEndPoint.top - (dragModal.mouseStartPoint.top - dragModal.basePoint.top);
        }
        dragModal.moveTarget.offset(dragModal.mouseEndPoint);
    });
    $(document).on('hidden.bs.modal','.modal',function(e){
        $('.modal-dialog').css({'top': '0px','left': '0px'})
        $('body').removeClass('select')
        document.body.onselectstart=document.body.ondrag=null;
    })
    $(function() {
        if(ID==""){
            alert("请先登录！");
            location.href='../main/login';
        }
    });

   /* function toModify(ppDetailid,ppNumber){
        $('#editShiyongyuanzeModal').modal();
        $("#myModalLabel_shiyongyuanze").html("序号："+ppNumber+"选择理由");
        vote.detailid=ppDetailid;
        vote.bindShiyongyuanze();
    }*/
</script>
</html>